package store.swing;

import store.swing.order.OrderPanel;
import store.swing.product.ProductPanel;

import javax.swing.*;
import java.awt.*;

public class MainPanel extends JPanel {
    private ProductPanel productPanel;
    private OrderPanel orderPanel;

    public MainPanel() {
        productPanel = new ProductPanel();
        orderPanel = new OrderPanel();
        initComponents();
    }

    private void initComponents() {
        setLayout(new GridBagLayout());
        ((GridBagLayout) getLayout()).columnWidths = new int[]{0, 150, 0};
        ((GridBagLayout) getLayout()).rowHeights = new int[]{0, 0};
        ((GridBagLayout) getLayout()).columnWeights = new double[]{1.0, 0.0, 1.0E-4};
        ((GridBagLayout) getLayout()).rowWeights = new double[]{1.0, 1.0E-4};

        Insets insets = new Insets(0, 0, 0, 0);
        GridBagConstraints c = new GridBagConstraints();

        insets.set(5,5,5,5);
        c.insets = insets;
        c.gridx = 0;
        c.gridy = 0;
        c.anchor = GridBagConstraints.CENTER;
        c.fill = GridBagConstraints.BOTH;
        add(productPanel, c);

        orderPanel.setVisible(false);
        add(orderPanel, c);

        insets.set(40,5,5,10);
        c.insets = insets;
        c.gridx = 1;
        c.gridy = 0;
        c.anchor = GridBagConstraints.NORTH;
        c.fill = GridBagConstraints.HORIZONTAL;
        add(new MenuPanel(),c);
    }
}
